package com.example.gzysmartcity.ui.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.gzysmartcity.R;
import com.example.gzysmartcity.repository.model.MyTravel;
import com.example.gzysmartcity.repository.model.SCTravel;

import org.jetbrains.annotations.NotNull;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;

public class TravelRvAdapter extends BaseQuickAdapter<SCTravel.DataBean, BaseViewHolder> {
    private final SimpleDateFormat simpleDateFormat;

    public TravelRvAdapter(int layoutResId) {
        super(layoutResId);
        simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, SCTravel.DataBean dataBean) {
        ImageView imageView = baseViewHolder.getView(R.id.imgRvItemTravel);
//        Glide.with(getContext()).load(myTravelList.get(baseViewHolder.getAdapterPosition()).getImgList().get(0)).into(imageView);
        Glide.with(getContext()).load(dataBean.getImgUrl()).into(imageView);
        baseViewHolder.setText(R.id.tvRvItemTravel1, dataBean.getName());
        baseViewHolder.setText(R.id.tvRvItemTravel2, "开始时间：\t" + simpleDateFormat.format(new Date((long) dataBean.getStartTime() * 1000)));
        baseViewHolder.setText(R.id.tvRvItemTravel3, "结束时间：\t" + simpleDateFormat.format(new Date((long) dataBean.getEndTime() * 1000)));
    }
}
